package com.wendyxie.sproutup.utils

import android.content.Context

class SPUtil {

    companion object {

        val SP_APP = "app"
        val KEY_USER_ID = "userId"
        val KEY_BABY_ID = "babyId"

        fun setUserId(context: Context, userId: String) {
            val sp = context.getSharedPreferences(SP_APP, Context.MODE_PRIVATE)
            val editor = sp.edit()
            editor.putString(KEY_USER_ID, userId)
            editor.apply()
        }
        fun getUserId(context: Context): String {
            val sp = context.getSharedPreferences(SP_APP, Context.MODE_PRIVATE)
            return sp.getString(KEY_USER_ID, "1").toString()
        }

        fun setBabyId(context: Context, babyId: String) {
            val sp = context.getSharedPreferences(SP_APP, Context.MODE_PRIVATE)
            val editor = sp.edit()
            editor.putString(KEY_BABY_ID, babyId)
            editor.apply()
        }
        fun getBabyId(context: Context): String {
            val sp = context.getSharedPreferences(SP_APP, Context.MODE_PRIVATE)
            return sp.getString(KEY_BABY_ID, "1").toString()
        }
    }
}
